package com.taotao.controller;

import com.taotao.factory.TemplateFactory;
import com.taotao.template.DistributedLockTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangjin
 * @title: TemplateController
 * @projectName designmodule
 * @description: TODO
 * @date 2022/6/18 0018 21:07
 */
@RestController
@Slf4j
public class TemplateController {

    @RequestMapping("templateLock")
    public String  templateLock(String templateId){
        DistributedLockTemplate payCallbackTemplate = TemplateFactory.getPayCallbackTemplate(templateId);
        try {
            payCallbackTemplate.LockTemplate();
            log.info("<lockTest>");
            payCallbackTemplate.unlockTemplate();
            return "ok";
        } catch (Exception e) {
            payCallbackTemplate.unlockTemplate();
            return "error";
        }
    }
}
